package sng.modules.view.components.city.strategy
{
	import flash.events.TimerEvent;
	
	import sng.data.info.GlobalInfo;
	import sng.data.info.GlobalTimer;
	import sng.modules.model.vo.BuildingVO;
	import sng.modules.model.vo.UserBuildingVO;
	import sng.modules.view.components.city.logic.unit.BaseBuilding;
	import sng.modules.view.components.city.state.EnumBuildState;
	import sng.utils.TimeUtil;
	
	/**
	 * 
	 * @author leonliu
	 * 仓库策略类
	 * 
	 */	
	public class StorageStrategy extends Strategy
	{
		public function StorageStrategy(building:BaseBuilding, bvo:BuildingVO, userbvo:UserBuildingVO)
		{
			super(building, bvo, userbvo);
		}
		
		public override function createBuildingStrategy():BuildingIncrement
		{
			//1.计算新建开始的数值变化
			GlobalInfo.mainvo.money=GlobalInfo.mainvo.money-m_bvo.buildingprice;			
			return new BuildingIncrement();
		}
		
		public override function addBuildingStrategy():void
		{
			super.addBuildingStrategy();
			//1.计算新建后的数值变化
			GlobalInfo.mainvo.goodsuplimit+=200;
			
			//2.新建后建筑变成 normal 
			buildStateManage(EnumBuildState.NORMAL_STATE);
					
		}
		
		
		
		
		
		/**
		 *心跳 
		 * 
		 */		
		protected override function heartBeat(event:TimerEvent):void
		{
			tip.gotoAndStop(tipFrame);
			switch(m_building.currentState.getiStateType())
			{
				case EnumBuildState.NORMAL_STATE:
				{
					//var time:Number = TimeUtil.getTimeSecond();
					//tip.timeText.text = TimeUtil.getTimeStringFromSecond(m_userbvo.countdownTime-time);
				
								
					break;
				}
				default:
				{
					
				}
			}			
		}
		
		
		/**
		 * 
		 * @param iState
		 * 仓库建筑各状态下的UI管理
		 * 
		 */		
		public override function buildStateManage(iState:uint):void
		{
			m_building.setBuildState(EnumBuildState.getStateById(iState));
			switch (iState)
			{
				case EnumBuildState.NEW_STATE:
					tipFrame = "building_create";
					break;
				case EnumBuildState.NORMAL_STATE:
					tipFrame = "house";
					break;
							
			}
		}
		
	}
}